package com.xqh.controller.ques;

import com.xqh.commom.BaseController;
import com.xqh.base.util.response.RespMsg;
import com.xqh.base.util.serializer.ObjectUtils;
import com.xqh.entity.ques.Book;
import com.xqh.entity.ques.BookUnit;
import com.xqh.service.ques.BookService;
import com.xqh.service.ques.BookUnitService;
import com.xqh.service.ques.MaterialTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/ques/book")
public class QuesBookController extends BaseController {

    @Autowired
    private BookService bookService;

    @Autowired
    private BookUnitService unitService;

    @Autowired
    private MaterialTypeService materialTypeService;

    /**
     * 获取书本 数据
     * @return
     */
    @RequestMapping(value = "bookData", method = RequestMethod.POST)
    public @ResponseBody
    RespMsg<?> bookData(Book book){
        List<Book> books = bookService.findByBiz(ObjectUtils.changeToMap(book));
        return RespMsg.successResp(books);
    }

    @RequestMapping(value = "unitData", method = RequestMethod.POST)
    @ResponseBody
    public RespMsg<?> unitData(BookUnit unit){
        List<BookUnit> ulist = unitService.findByBiz(ObjectUtils.changeToMap(unit));
        return RespMsg.successResp(ulist);
    }
}
